<!-- include ajax form updater -->
<script language="JavaScript" type="text/javascript" src="{$INA.adminTemplate}javascript/users.js"></script>
<!-- end include ajax form updater -->

<!-- Left Rail -->
<div class="lCol">
    <h2 class="subheader helpico" {popup width="200" text="Members of <b>Super Groups</b> have no access restrictions. Members of <b>Standart Groups</b> may access the admin panel. Members of <b>Public Groups</b> have access to client side applications only."}>User Groups</h2>
    <div id="fresh_all">
        <table class="latest" cellspacing="0">
            <tbody>
            {foreach from=$adminGroups item=group}
                <tr class="{cycle values="shade,noshade"}" id="group_{$group.id}">
                    <td class="icon">
                        {if $group.id == 1}
                            <img alt="Super Users Group" src="{$INA.adminTemplate}images/stat_super.gif" align="middle" {popup text="Super Users have system wide access with no restrictions whatsoever!"}>
                        {elseif $group.id < 1000}
                            <img alt="Standart Users Group" src="{$INA.adminTemplate}images/stat_standart.gif" align="middle">
                        {else}
                            <img alt="Public Users Group" src="{$INA.adminTemplate}images/stat_public.gif" align="middle">
                        {/if}
                    </td>
                    <td class="title" id="group_{$group.id}_data">
                        <span id="group_{$group.id}_title">
                            <a class="messagelink glink" href="javascript: showGroupInfo({$group.id})"><span id="group_{$group.id}_name">{$group.name}</span></a>
                        </span>
                        
                        <p class="excerpt">
                          <strong>Group Members:</strong>
                          <span id="members_{$group.id}">
                          {foreach from=$group.members item=member name=members}
                            <span id="user_{$member.id}"><span class="adminuser"><a href="javascript: showUserInfo({$member.id})">{$member.login}</a></span>{if !$smarty.foreach.members.last} {/if}</span>
                          {foreachelse}
                            n/a
                          {/foreach}
                          </span>
                        </p>
                    </td>
                </tr>
            {foreachelse}
                <tr class="shade">
                    <td class="icon"><img alt="Not Available" src="{$INA.adminTemplate}images/stat_na.gif" align="middle"></td>
                    <td class="title">
                        No Administrative Groups Listed in the System
                    </td>
                </tr>
            {/foreach}
            </tbody>
        </table>
    </div>
</div>
<!-- End Left Rail -->

<!-- RIGHT RAIL -->
<div class="rCol">
    <div id="userInfo">     
        
    </div>
    
    <div class="SectionHeader">
        <h2>Things you can do</h2>

        <div class="thingsYouCanDo">
          <a class="admin" href="{$INA.this}" id="addAdmin" onClick="hide('addGroupForm'); hide('confirm'); return unhide('addUserForm',true);">Add User</a> |
          <a class="admin" href="{$INA.this}" id="addGroup" onClick="hide('addUserForm'); hide('confirm'); return unhide('addGroupForm',true);">Add Group</a> 
        </div>
        
        
        {if $smarty.get.confirmNewUser}
            <div id="confirm">
                Successfuly added new user!
            </div>
        {/if}
        
        
        <form name="adduser" method="post" action="{$INA.this}" id="addUserForm" {if !$userErrors}style="display: none;"{/if}>
            <table class="smallForm">
            <tr><td>Please fill out the form below. All fields are mandatory. To get help on a field's content, simply put your mouse over the field's label.</td></tr>
            <tr><td>
                <label for="addUserLogin"  {popup text="This is the user name under which this user will be distinguished from others in the system. It is essential that this name is unique and does not contain spaces and consists of alphanumeric characters only. A dot, hyphen und an underscore are also permitted." width="200" delay="0"}>Login</label><br />
                <input name="login" value="{$smarty.post.login}" id="addUserLogin" class="textInput {if $userErrors.login or $userErrors.loginTaken}error{/if}" maxlength="128" />
                {if $userErrors.login}
                    <span class="errorMessage">Please provide a valid login name containing only alphanumeric characters, dots or hyphens, minimum 3 charachters in length.</span>
                {elseif $userErrors.loginTaken}
                    <span class="errorMessage">The selected login name is already occupied by another user, please choose again.</span>
                {/if}
                
            </td></tr><tr><td>
                <label for="addUserFullName" {popup text="The full name of the user is neccessary for information gathering purposes only, yet it is required." width="200" delay="0"}>Full Name</label><br />
                <input name="fullName" value="{$smarty.post.fullName}" id="addUserFullName" class="textInput {if $userErrors.fullName}error{/if}" maxlength="254" />
                {if $userErrors.fullName}
                    <span class="errorMessage">Please provide some sort of full name</span>
                {/if}
                
            </td></tr><tr><td>
                <label for="addUserEMail" {popup text="It is essential to indicate a valid e-mail address, as a freshly generated password will be e-mail there." width="200" delay="0"}>E-Mail</label><br />
                <input name="eMail" value="{$smarty.post.eMail}" id="addUserEMail" class="textInput {if $userErrors.eMail}error{/if}" maxlength="128" />
                {if $userErrors.eMail}
                    <span class="errorMessage">Please provide a valid e-mail</span>
                {/if}
                
            </td></tr><tr><td>
                <label for="addUserGroup" {popup text="Choose a group to which the user will belong to. The group indicates the user's access permissions on the system-wide level." width="200" delay="0"}>Primary Group</label><br />
                <select id="addUserGroup" class="selectInput" name="group">
                    {html_options options=$groups selected=$smarty.post.group}
                </select>
                
            </td></tr><tr><td>
                <input type="submit" name="submitNewUser" value="Add User" class="submitInput" /> <a class="admin" href="{$INA.this}" onClick="return hide('addUserForm',true);">Cancel</a>
            </td></tr></table>
        </form>
        
        
        {if $smarty.get.confirmNewGroup}
            <div id="confirm">
                Successfuly added new group!
            </div>
        {/if}
            
        <form name="addgroup" method="post" action="{$INA.this}" id="addGroupForm" {if !$groupErrors}style="display: none;"{/if}>
            <table class="smallForm">
            <tr><td>Please fill out the form below. All fields are mandatory. To get help on a field's content, simply put your mouse over the field's label.</td></tr>
            <tr><td>
                <label for="addGroupName" {popup text="The name of the group will help you distinguish it from other groups" width="200" delay="0"}>Group Name</label><br />
                <input type="text" name="name" value="" id="addGroupName" class="textInput {if $groupErrors.name}error{/if}" maxlength="128" />
                {if $groupErrors.name}
                    <span class="errorMessage">Please provide a group name</span>
                {/if}
            </td></tr>
            <tr><td>
                <label for="addGroupAdmin" {popup text="Members of Administrative groups have access to the Admin Panel" width="200" delay="0"}>Administrative Group?</label><br />
                <input type="checkbox" name="admin" value="1" class="checkboxInput" id="addGroupAdmin" />
                
            </td></tr>
            <tr><td>
                <input type="submit" name="submitNewGroup" value="Add Group" class="submitInput" /> <a class="admin" href="{$INA.this}" onClick="return hide('addGroupForm',true);">Cancel</a>
            </td></tr></table>
        </form>
    </div>
</div>
<!-- END RIGHT RAIL -->
{if $smarty.cookies.probableUser}
    <script language="JavaScript" type="text/javascript">showUserInfo({$smarty.cookies.probableUser});</script>
{/if}